package com.ncst.backend.service.impl;

import com.ncst.backend.domain.Admin;
import com.ncst.backend.mapper.AdminMapper;
import com.ncst.backend.service.AdminService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * 管理员服务实现
 */
@Slf4j
@Service
@RequiredArgsConstructor
public class AdminServiceImpl implements AdminService {

    private final AdminMapper adminMapper;

    @Override
    public Admin findByCode(String code) {
        return adminMapper.selectByAdminCode(code);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean create(Admin admin) {
        return adminMapper.insert(admin) > 0;
    }
}
